home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / xmasspak / vector / vector9.asm < prev    next >
Encoding:
Assembly Source File  |  1995-08-19  |  22.9 KB  |  1,149 lines

  1. ;
  2. ;  Line-Vector-routine v2.2
  3. ;
  4. ;  done 1995 by Capella/Escape
  5. ;  this routine is only for Escape-usage .... DON'T SPREAD!!!!
  6. ;
  7.  
  8. ideal
  9. model large
  10. p386n
  11. stack 256
  12.  
  13. assume cs:coding
  14.  
  15. points = 6                ; Anzahl Punkte
  16. areas = 11              ; Anzahl Linien
  17. frames = 2              ; Anzahl Flächen 
  18. ;-------------------------------------
  19. macro  setcol   backcol
  20.  
  21.        mov dx,03c8h
  22.        xor al,al
  23.        out dx,al
  24.        inc dx
  25.        mov al,backcol
  26.        out dx,al
  27.        out dx,al
  28.        out dx,al
  29.  
  30. endm
  31. ;-------------------------------
  32. macro  setpage newpage
  33.  
  34.        mov dx,03d4h
  35.        mov ax,newpage
  36.        out dx,ax
  37.  
  38. endm
  39. ;-------------------------------
  40.  
  41. segment  coding
  42.  
  43. start:     mov ax,data1
  44.            mov ds,ax
  45.            assume ds:data1
  46.  
  47.            mov ax,0a000h
  48.            mov es,ax
  49.            assume es:0a000h
  50.  
  51.            call set320400
  52.           ;  call set640400
  53.  
  54.            mov ax,0a800h
  55.            mov es,ax
  56.            assume es:0a800h
  57.  
  58.            mov cx,4*3
  59.            mov si,offset colorpal
  60.            mov dx,03c8h
  61.            xor al,al
  62.            out dx,al
  63.            inc dx
  64. setpal1:   mov al,[ds:si]
  65.            out dx,al
  66.            inc si
  67.            dec cx
  68.            jnz setpal1
  69.  
  70. main:      call  rotate_x       
  71.            call  rotate_y
  72.            call  rotate_z
  73.  
  74.            call transform
  75.            
  76.            mov [ds:color],1         ; Objekt auf Seite 2 darstellen
  77.            mov di,offset _2dpoints
  78.          ;  call draw_obj
  79.            call fill_obj
  80.            
  81.            
  82.  
  83.            setpage 800ch           ; Seite 2 an
  84.            
  85.            mov dx,03dah
  86. wb1:       in al,dx
  87.            test al,8
  88.            jne wb1
  89. wb2:       in al,dx
  90.            test al,8
  91.            je wb2
  92.  
  93.            mov ax,0a000h
  94.            mov es,ax
  95.            assume es:0a000h
  96.            
  97.            mov dx,03c4h
  98.            mov ax,0f02h
  99.            out dx,ax
  100.  
  101.            mov cx,32000/4        ; Objekt auf Seite 1 löschen
  102.            xor si,si
  103.            xor eax,eax
  104. del_p1:    mov [es:si],eax
  105.            add si,4
  106.            dec cx
  107.            jnz del_p1
  108.            
  109.            
  110.  
  111.            call get_oldpos         ; Positionen von Seite 2 retten
  112.            
  113.            
  114.           
  115.           ;add [ds:xw],2
  116.           ; add [ds:yw],2
  117.           ; add [ds:zw],2
  118.            
  119.            call rotate_x        
  120.            call rotate_y
  121.            call rotate_z
  122.            
  123.            call transform
  124.            
  125.            mov [ds:color],1        ; Objekt auf Seite 1 darstellen
  126.            mov di,offset _2dpoints
  127.         ;   call draw_obj
  128.            call fill_obj
  129.            
  130.            setpage 000ch           ; Seite 1 an
  131.        
  132.            mov dx,03dah
  133. wb3:       in al,dx
  134.            
  135.            test al,8
  136.            jne wb3
  137. wb4:       in al,dx
  138.            test al,8
  139.            je wb4
  140.  
  141.            mov ax,0a800h
  142.            mov es,ax
  143.            assume es:0a800h
  144.            
  145.            mov dx,03c4h
  146.            mov ax,0f02h
  147.            out dx,ax
  148.  
  149.            mov cx,32000/4
  150.            xor si,si
  151.            xor eax,eax
  152. del_p2:    mov [es:si],eax
  153.            add si,4
  154.            dec cx
  155.            jnz del_p2
  156.            
  157.            call get_oldpos         ; Positionen von Seite 1 retten
  158.            
  159.            add [ds:xw],2        ; Neue Winkel berechnen
  160.            add [ds:yw],4
  161.            add [ds:zw],2
  162.            
  163. warte:     in al,60h            ; Auf 'ESCAPE'-Taste warten
  164.            cmp al,01
  165.            jne main
  166.  
  167.            
  168. exit:      mov ax,0003h
  169.            int 10h
  170.            mov ax,4c00h
  171.            int 21h
  172.  
  173. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  174. ; ROTATIONS-ROUTINE / dreht die 3d-koordinaten in x,y und z-richtung
  175. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  176.  
  177. proc  rotate_x    NEAR
  178.      
  179.      mov   si,offset xpos
  180.      mov   di,offset _3dpoints
  181.      mov   cx,points
  182.  
  183. rotx_it:
  184.      push  cx
  185.      
  186.      mov   ax,[ds:zw]       
  187.      call  cosinus
  188.      imul  [word ds:si]
  189.      mov   cx,dx
  190.      mov   ax,[ds:zw] 
  191.      call  sinus
  192.      imul  [word ds:si+2*points]
  193.      sub   dx,cx
  194.      sal   dx,1
  195.      sal   dx,1
  196.      mov   [ds:di],dx  
  197.  
  198.      mov   ax,[ds:zw]       
  199.      call  sinus
  200.      imul  [word ds:si]
  201.      mov   cx,dx
  202.      mov   ax,[ds:zw] 
  203.      call  cosinus
  204.      imul  [word ds:si+2*points]
  205.      add   dx,cx
  206.      sal   dx,1
  207.      sal   dx,1
  208.      mov   [ds:di+2*points],dx                
  209.       
  210.      pop cx
  211.      add si,2
  212.      add di,2
  213.      dec cx
  214.      jnz rotx_it
  215.      ret
  216.  
  217. endp  rotate_x
  218.  
  219. proc  rotate_y    NEAR
  220.  
  221.      mov cx,points
  222.      mov si,offset xpos
  223.      mov di,offset _3dpoints
  224.  
  225. roty_it:     
  226.      push cx
  227.  
  228.      mov   ax,[ds:yw]       
  229.      call  cosinus
  230.      imul  [word ds:si]
  231.      mov   cx,dx
  232.      mov   ax,[ds:yw] 
  233.      call  sinus
  234.      imul  [word ds:si+4*points]
  235.      sub   dx,cx
  236.      sal   dx,1
  237.      sal   dx,1
  238.      mov   [ds:di],dx  
  239.  
  240.      mov   ax,[ds:yw]       
  241.      call  sinus
  242.      imul  [word ds:si]
  243.      mov   cx,dx
  244.      mov   ax,[ds:yw] 
  245.      call  cosinus
  246.      imul  [word ds:si+4*points]
  247.      add   dx,cx
  248.      sal   dx,1
  249.      sal   dx,1
  250.      mov   [ds:di+4*points],dx                
  251.       
  252.      pop cx
  253.      add si,2
  254.      add di,2
  255.      dec cx
  256.      jnz roty_it
  257.      ret
  258.  
  259. endp  rotate_y
  260.  
  261. proc  rotate_z    NEAR
  262.  
  263.      mov cx,points
  264.      mov si,offset xpos
  265.      mov di,offset _3dpoints
  266.  
  267. rotz_it:
  268.      
  269.      push cx
  270.  
  271.      mov   ax,[ds:xw]       
  272.      call  cosinus
  273.      imul  [word ds:si+2*points]
  274.      mov   cx,dx
  275.      mov   ax,[ds:xw] 
  276.      call  sinus
  277.      imul  [word ds:di+4*points]
  278.      sub   dx,cx
  279.      sal   dx,1
  280.      sal   dx,1
  281.      mov   [ds:di+2*points],dx  
  282.  
  283.      mov   ax,[ds:xw]       
  284.      call  sinus
  285.      imul  [word ds:si+2*points]
  286.      mov   cx,dx
  287.      mov   ax,[ds:xw] 
  288.      call  cosinus
  289.      imul  [word ds:di+4*points]
  290.      add   dx,cx
  291.      sal   dx,1
  292.      sal   dx,1
  293.      mov   [ds:di+4*points],dx                
  294.      
  295.      pop   cx
  296.      add si,2
  297.      add di,2
  298.      dec cx
  299.      jnz rotz_it
  300.      ret
  301.  
  302. endp  rotate_z
  303.  
  304. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  305. ; DRAW-OBJECT / zeichnet das object bestehend aus den 2d-koordinaten
  306. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  307.  
  308. proc  draw_obj    NEAR
  309.      
  310.      mov dx,03c4h
  311.      mov ax,0102h
  312.      out dx,ax
  313.      
  314.      mov   si,offset lines
  315.      mov   cx,areas
  316.  
  317. Draw_Bonds:
  318.      
  319.      push  cx
  320.      xor   bh,bh
  321.      mov   bl,[ds:si]    
  322.      shl   bl,1
  323.      mov   ax,[ds:di+bx]        
  324.      mov   cx,[ds:di+2*points+bx] 
  325.      mov   [ds:x1],ax
  326.      mov   [ds:y1],cx
  327.      inc   si
  328.      mov   bl,[ds:si]
  329.      shl   bl,1
  330.      mov   ax,[ds:di+bx]        
  331.      mov   cx,[ds:di+2*points+bx]  
  332.      mov   [ds:x2],ax
  333.      mov   [ds:y2],cx
  334.      push  si
  335.      push  di
  336.      call  drawline
  337.      pop   di
  338.      pop   si
  339.      inc   si
  340.      pop   cx
  341.      dec cx
  342.      jnz  Draw_Bonds
  343.      ret
  344.  
  345. endp  draw_obj 
  346.  
  347. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  348. ; TRANSFORMATION-ROUTINE / rechnet die 3d-koord. in 2d koord. um
  349. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  350.  
  351. proc  transform     NEAR
  352.      
  353.          mov   cx,points
  354.          mov   di,offset _2dpoints
  355.          mov   si,offset _3dpoints
  356.  
  357. trans_it:mov   bx,[ds:si+4*points] 
  358.          sub   bx,[ds:dist]
  359.      
  360.          mov   ax,[ds:dist]
  361.          imul  [word ds:si]
  362.          idiv  bx            
  363.          sar   ax,1
  364.          sar   ax,1
  365.          sar   ax,1
  366.          sar   ax,1
  367.          add   ax,[ds:x_add]
  368.          mov   [ds:di],ax      
  369.      
  370.          mov   ax,[ds:dist]
  371.          imul  [word ds:si+2*points]
  372.          idiv  bx
  373.          sar   ax,1
  374.          sar   ax,1
  375.          sar   ax,1
  376.          sar   ax,1
  377.          add   ax,[ds:y_add]
  378.          mov   [ds:di+2*points],ax 
  379.      
  380.          add si,2
  381.          add di,2
  382.          dec cx
  383.          jnz trans_it
  384.          ret
  385.  
  386. endp  transform 
  387.  
  388. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  389. ; COSINUS-ROUTINE
  390. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  391.  
  392. proc  cosinus     NEAR
  393.  
  394.      add   ax,64
  395.  
  396.      push  bx
  397.      push  cx
  398.      push  si
  399.      
  400.      mov   bx,ax
  401.      shl   ax,1
  402.      and   ax,0ffh       
  403.      mov   si,offset sinustable
  404.      add   si,ax
  405.      mov   ax,[ds:si]     
  406.      clc
  407.      shl   bl,1         
  408.      jae   cos_pos
  409.      neg   ax            
  410. cos_pos:
  411.      pop   si
  412.      pop   cx
  413.      pop   bx
  414.      ret
  415.  
  416. endp  cosinus
  417.  
  418. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  419. ; SINUS-ROUTINE
  420. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  421.  
  422. proc  sinus    NEAR
  423.  
  424.      push  bx
  425.      push  cx
  426.      push  si
  427.      
  428.      mov   bx,ax
  429.      shl   ax,1
  430.      and   ax,0ffh       
  431.      mov   si,offset sinustable
  432.      add   si,ax
  433.      mov   ax,[ds:si]     
  434.      clc
  435.      shl   bl,1         
  436.      jae   sin_pos
  437.      neg   ax            
  438. sin_pos:
  439.      pop   si
  440.      pop   cx
  441.      pop   bx
  442.      ret
  443.  
  444. endp  sinus
  445.  
  446. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  447. ; DRAWLINE-ROUTINE / zieht eine linie von x1,y1 nach x2,y2 mit farbe col
  448. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  449.  
  450. proc  drawline   NEAR
  451.      
  452.      mov   ax,[ds:x1]
  453.      cmp   ax,[ds:x2]
  454.      jz    no_xadd
  455.      jmp   draw_it
  456.  
  457. no_xadd:
  458.      
  459.      mov   ax,[ds:y1]
  460.      cmp   ax,[ds:y2]
  461.      jnz   draw_it
  462.      
  463.      mov ax,[ds:x1]
  464.      mov bx,[ds:y1]
  465.      jmp   stop_line
  466.  
  467. draw_it:
  468.      
  469.      push  bp
  470.      mov   ax,[ds:x1]
  471.      mov   bx,[ds:y1]
  472.      push  ax
  473.      push  bx
  474.      mov   bx,4340h
  475.      mov   cx,[ds:x2]
  476.      sub   cx,ax
  477.      jge   deltax_1
  478.      mov   bl,48h
  479.      neg   cx
  480.  
  481. deltax_1:
  482.      
  483.      mov   dx,[ds:y2]
  484.      pop   si
  485.      push  si
  486.      sub   dx,si
  487.      jge   deltay_1
  488.      mov   bh,4bh
  489.      neg   dx
  490.  
  491. deltay_1:
  492.  
  493.      mov   si,offset line_add
  494.      mov   [word cs:si],bx
  495.      cmp   cx,dx
  496.      jge   deltax_2
  497.      mov   bl,90h
  498.      xchg  cx,dx
  499.      jmp   achse3
  500.  
  501. deltax_2:
  502.      
  503.      mov   bh,90h
  504.  
  505. achse3:
  506.      
  507.      mov   si,offset line_sub
  508.      mov   [word cs:si],bx
  509.      shl   dx,1
  510.      mov   bp,dx
  511.      sub   dx,cx
  512.      mov   di,dx
  513.      sub   dx,cx
  514.      pop   bx
  515.      pop   ax
  516.  
  517. line_loop:
  518.      
  519.      push  di
  520.      push  ax
  521.      push  dx
  522.      push  bx
  523.      push  cx
  524.      
  525.      push ax
  526.      mov ax,80
  527.      imul bx
  528.      pop cx
  529.      mov bx,cx
  530.      shr bx,1
  531.      shr bx,1
  532.      add ax,bx
  533.      mov si,ax
  534.  
  535.      and cl,3
  536.      mov ah,1
  537.      shl ah,cl
  538.      mov dx,03c4h
  539.      mov al,02h
  540.      out dx,ax
  541.  
  542.      mov al,[ds:color]
  543.      mov [es:si],al
  544.      
  545.  
  546.      
  547.      pop   cx
  548.      pop   bx
  549.      pop   dx
  550.      pop   ax
  551.      pop   di
  552.      cmp   di,0
  553.      jge   line_add
  554.  
  555. line_sub:
  556.      
  557.      inc   ax
  558.      inc   bx
  559.      add   di,bp
  560.      loop  line_loop
  561.      jmp   end_line
  562.  
  563. line_add:
  564.      
  565.      inc   ax
  566.      inc   bx
  567.      add   di,dx
  568.      loop  line_loop
  569.  
  570. end_line:
  571.      
  572.      pop     bp
  573.  
  574. stop_line:
  575.      
  576.      ret
  577.  
  578. endp  drawline 
  579.  
  580.  
  581.  
  582. proc  get_oldpos  NEAR
  583.  
  584.          mov cx,2*points
  585.  
  586.          mov si,offset _2dpoints
  587.          mov di,offset old2d
  588.  
  589. old_loop:mov ax,[ds:si]
  590.          mov [ds:di],ax
  591.          add si,2
  592.          add di,2
  593.          dec cx
  594.          jnz old_loop
  595.          
  596.          ret
  597.  
  598. endp  get_oldpos
  599.  
  600. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  601. ; FÜLLROUTINE V1.0
  602. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  603.  
  604. fill_obj  :  mov cx,frames
  605.              mov si,offset frame
  606.              mov di,offset _2dpoints
  607.              
  608. fill_obj1:   mov bl,[ds:si]
  609.              xor bh,bh
  610.              shl bx,1
  611.  
  612.              mov ax,[ds:di+bx] ;get 1st point of frame
  613.              mov [ds:t_x1],ax
  614.              mov ax,[ds:di+2*points+bx]
  615.              mov [ds:t_y1],ax
  616.  
  617.              inc si
  618.  
  619.              mov bl,[ds:si]
  620.              xor bh,bh
  621.              shl bx,1
  622.  
  623.              mov ax,[ds:di+bx]
  624.              mov [ds:t_x2],ax
  625.              mov ax,[ds:di+2*points+bx]
  626.              mov [ds:t_y2],ax
  627.  
  628.              inc si
  629.  
  630.              mov bl,[ds:si]
  631.              xor bh,bh
  632.              shl bx,1
  633.  
  634.              mov ax,[ds:di+bx]
  635.              mov [ds:t_x3],ax
  636.              mov ax,[ds:di+2*points+bx]
  637.              mov [ds:t_y3],ax
  638.  
  639.              inc si
  640.  
  641.             
  642.              push cx
  643.              push si
  644.              push di
  645.  
  646.              mov si,offset colors
  647.              add si,cx
  648.              mov al,[ds:si]
  649.              mov [ds:color],al
  650.  
  651.              call draw_polygon
  652.  
  653.              pop di
  654.              pop si
  655.              pop cx
  656.  
  657. no_fill:     dec cx
  658.              jnz fill_obj1
  659.  
  660.              ret
  661.  
  662. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  663. ; SET 320*400 Graphics-mode (based on 4 bitplane-splitting) 
  664. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  665.  
  666. proc  set320400  NEAR
  667.  
  668.               mov ax,0013h      
  669.               int 10h
  670.  
  671.               mov dx,03c4h
  672.               mov al,04h
  673.               out dx,al
  674.               inc dx
  675.               in al,dx
  676.               and al,11110111b
  677.               out dx,al
  678.               dec dx
  679.               
  680.               mov ax,0f02h
  681.               out dx,ax
  682.  
  683.               mov dx,03d4h
  684.               mov al,14h
  685.               out dx,al
  686.               inc dx
  687.               in al,dx
  688.               and al,10111111b
  689.               out dx,al
  690.               dec dx
  691.               mov al,17h
  692.               out dx,al
  693.               inc dx
  694.               in al,dx
  695.               or al,01000000b
  696.               out dx,al
  697.  
  698.               mov dx,03d4h
  699.               mov al,09h
  700.               out dx,al
  701.               inc dx
  702.               in al,dx
  703.               and al,01110000b
  704.               out dx,al
  705.               
  706.               mov dx,03c4h
  707.               mov ax,0f02h
  708.               out dx,ax
  709.  
  710.               mov ax,0a000h
  711.               mov es,ax
  712.               assume es:0a000h
  713.               
  714.               mov cx,64000      ; alle bitplanes auf beiden grafikseiten
  715.               xor di,di         ; löschen...
  716.               xor eax,eax
  717.               cld
  718.               rep stosd
  719.  
  720.               ret
  721.  
  722. endp  set320400
  723.  
  724. proc  set640400  NEAR
  725.  
  726.               mov ax,000eh
  727.               int 10h
  728.  
  729.               mov dx,03d4h
  730.               mov al,09h
  731.               out dx,al
  732.               inc dx
  733.               in al,dx
  734.               and al,01111111b
  735.               out dx,al
  736.  
  737.               ret
  738.  
  739. endp  set640400
  740.  
  741. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  742. ; DRAWS A FILLED POLYGON WITH 3 POINTS 
  743. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  744.  
  745. draw_polygon:   mov ax,[ds:t_y1]
  746.                 cmp ax,[ds:t_y2]
  747.                 jbe s_ok_1
  748.  
  749.                 xchg ax,[ds:t_y2]
  750.                 mov [ds:t_y1],ax
  751.                 mov ax,[ds:t_x1]
  752.                 xchg ax,[ds:t_x2]
  753.                 mov [ds:t_x1],ax
  754.  
  755. s_ok_1:         mov ax,[ds:t_y2]
  756.                 cmp ax,[ds:t_y3]
  757.                 jbe s_ok_3
  758.                 
  759.                 xchg ax,[ds:t_y3]
  760.                 mov [ds:t_y2],ax
  761.                 mov ax,[ds:t_x3]
  762.                 xchg ax,[ds:t_x2]
  763.                 mov [ds:t_x3],ax
  764.  
  765. s_ok_2:         mov ax,[ds:t_y1]
  766.                 cmp ax,[ds:t_y2]
  767.                 jbe s_ok_3
  768.                 
  769.                 xchg ax,[ds:t_y2]
  770.                 mov [ds:t_y1],ax
  771.                 mov ax,[ds:t_x1]
  772.                 xchg ax,[ds:t_x2]
  773.                 mov [ds:t_x1],ax
  774.  
  775. s_ok_3:         mov bp,[ds:t_y3]
  776.                 mov dx,[ds:t_x3]
  777.                 mov ax,[ds:t_y1]
  778.                 mov bx,[ds:t_x1]
  779.                 mov di,offset buffer
  780.  
  781.                 call calc_line
  782.  
  783.                 mov bp,[ds:t_y2]
  784.                 mov dx,[ds:t_x2]
  785.                 mov ax,[ds:t_y1]
  786.                 mov bx,[ds:t_x1]
  787.                 mov di,offset buffer+2
  788.                 
  789.                 call calc_line
  790.  
  791.                 mov bp,[ds:t_y3]
  792.                 mov dx,[ds:t_x3]
  793.                 mov ax,[ds:t_y2]
  794.                 mov bx,[ds:t_x2]
  795.                 
  796.                 call calc_line
  797.  
  798.                 mov bx,01h
  799.                 
  800.                 mov bp,[ds:t_y3]
  801.                 sub bp,[ds:t_y1]
  802.                 inc bp
  803.  
  804.                 mov si,offset buffer
  805.  
  806.                 mov al,bl
  807.  
  808.                 imul dx,[ds:t_y1],ssizex/4
  809.  
  810. draw_nline:     mov di,[si]
  811.                 mov bx,[si+2]
  812.                 sub bx,di
  813.                 jnc width_pos
  814.  
  815.                 add di,bx
  816.                 neg bx
  817.  
  818. width_pos:      inc bx
  819.  
  820.                 push ax
  821.                 push dx
  822.                 call draw_line
  823.                 pop dx
  824.                 pop ax
  825.  
  826.                 add si,4
  827.                 add dx,ssizex/4
  828.                 dec bp
  829.                 jnz draw_nline
  830.  
  831. end_fill:       ret
  832.  
  833.  
  834.  
  835. calc_line:      xor cx,cx
  836.  
  837.                 sub bp,ax
  838.                 inc bp
  839.  
  840.                 sub dx,bx
  841.                 jnc dx_not_neg
  842.  
  843.                 mov cx,2
  844.                 neg dx
  845.  
  846. dx_not_neg:     inc dx
  847.                 mov ax,bx       ; Start address into ax
  848.  
  849.                 mov bx,1        ; assume x major
  850.                 sub bx,cx       ; see if going backwards
  851.                 mov cx,bp
  852.  
  853.                 cmp dx,bp       ; x major or y major?
  854.                 jbe x_major
  855.  
  856.                 mov cx,dx       ; else y major
  857.                 xchg bp,dx
  858.  
  859.                 mov si,bp
  860.  
  861. y_next_pixel:   sub si,dx       ; Dump = Dump - dy
  862.                 jnc y_positive
  863.  
  864.                 add si,bp       ; Dump = Dump + dx
  865.  
  866.                 mov [ds:di],ax
  867.                 add di,4
  868.  
  869. y_positive:     add ax,bx ; Add increment
  870.                 dec cx
  871.                 jnz y_next_pixel
  872.  
  873.                 sub ax,bx
  874.                 mov [ds:di],ax
  875.                 add di,4
  876.  
  877.                 jmp end_filled_triangle
  878.  
  879. x_major:        mov si,bp
  880.  
  881. x_next_pixel:   mov [ds:di],ax
  882.                 add di,4
  883.  
  884.                 sub si,dx ; Dump = Dump - dy
  885.                 jnc x_positive
  886.  
  887.                 add ax,bx ; Add increment
  888.                 add si,bp ; Dump = Dump + dx
  889.  
  890. x_positive:     dec cx
  891.                 jnz x_next_pixel
  892.  
  893. end_filled_triangle:    ret
  894.  
  895.  
  896.  
  897. draw_line:      mov cx,di
  898.                 shr di,2
  899.                 add di,dx
  900.  
  901.                 and cx,3
  902.                 add bx,cx
  903.                                                 
  904.                 mov ch,[ds:color]
  905.                 
  906.                 mov ax,0f02h
  907.                 shl ah,cl
  908.                 mov dx,03c4h
  909.                 sub bx,4
  910.                 jg not_same_nibble
  911.  
  912.                 neg bl
  913.                 mov cl,bl
  914.                 mov bh,0fh
  915.                 shr bh,cl
  916.                 and ah,bh
  917.                 out dx,ax
  918.                 
  919.                 mov [es:di],ch
  920.                 ret
  921.  
  922.  
  923. not_same_nibble:out dx,ax
  924.                 mov [es:di],ch
  925.                 inc di
  926.  
  927.                 cmp bx,3
  928.                 jle skip_rep
  929.                 
  930.                 mov ax,0f02h
  931.                 out dx,ax
  932.                 mov al,ch
  933.                 mov cx,bx
  934.                 shr cx,2
  935.  
  936.                 rep stosb
  937.  
  938.                 mov ch,al
  939. skip_rep:       and bx,3
  940.                 jz no_last_byte
  941.  
  942.                 mov cl,bl
  943.                 mov ax,0f002h
  944.                 rol ah,cl
  945.                 out dx,ax
  946.  
  947.                 mov [es:di],ch
  948.  
  949. no_last_byte:   ret              
  950.  
  951.  
  952. ends  coding
  953.  
  954. segment  data1
  955.  
  956.  
  957. color db 0
  958.  
  959. ssizex                                  equ 320
  960. ssizey                                  equ 327
  961.  
  962. t_x1                    dw 0
  963. t_y1                    dw 0
  964. t_x2                    dw 0
  965. t_y2                    dw 0
  966. t_x3                    dw 0
  967. t_y3                    dw 0
  968.  
  969. buffer                  dw 1000 dup(0)
  970.  
  971. ;
  972. ; OBJEKT DATEN
  973. ;
  974.  
  975. xpos     dw 500,500,-500,500,500,-500
  976.          
  977. ypos     dw 500,-500,000,500,-500,500
  978.          
  979. zpos     dw 500,500,500,1000,1000,1000
  980.          
  981.  
  982. ;
  983. ; BINDUNGSLISTE FÜR DIE OBJEKT-PUNKTE
  984. ;
  985.  
  986. lines db 2,0
  987.       db 2,3
  988.       db 0,3
  989.  
  990.       db 0,1
  991.       db 3,1
  992.  
  993.       db 3,4
  994.       db 1,4
  995.  
  996.       db 2,5
  997.       db 5,3
  998.  
  999.       db 5,6
  1000.       db 6,4
  1001.  
  1002.       db 0,7
  1003.       db 1,7
  1004.       db 2,7
  1005.       db 4,7
  1006.       db 5,7
  1007.       db 6,7
  1008.  
  1009.  
  1010.  
  1011. ; FLÄCHENLISTE FÜR FÜLLROUTINE
  1012. ;
  1013.  
  1014. frame db 0,1,2
  1015.  
  1016.       db 3,4,5
  1017.  
  1018.  
  1019. ;
  1020. ; FARBEN FÜR DIE EINZELNEN FLÄCHEN
  1021. ;
  1022.  
  1023. colors db 0,1,3,1,3,1,3 
  1024.        
  1025.        
  1026.  
  1027.  
  1028.  
  1029. ;
  1030. ; DISTANZ VOM AUGE DES BETRACHTERS IN DEN 3D-RAUM
  1031. ;
  1032.  
  1033. dist  dw 2000
  1034.  
  1035. ;
  1036. ; SINUSTABELLE MIT 128 WERTEN
  1037. ;
  1038.  
  1039. sinustable dw 0000h,0192h,0324h,04b5h,0646h
  1040.            dw 07d6h,0964h,0af1h,0c7ch,0e06h,0f8dh
  1041.            dw 1112h,1294h,1413h,1590h,1709h,187eh
  1042.            dw 19efh,1b5dh,1cc6h,1e2bh,1f8ch,20e7h
  1043.            dw 223dh,238eh,24dah,2620h,2760h,289ah
  1044.            dw 29ceh,2afbh,2c21h,2d41h,2e5ah,2f6ch
  1045.            dw 3076h,3179h,3274h,3368h,3453h,3537h
  1046.            dw 3612h,36e5h,37b0h,3871h,392bh,39dbh
  1047.            dw 3a82h,3b21h,3bb6h,3c42h,3cc5h,3d3fh
  1048.            dw 3dafh,3e15h,3e72h,3ec5h,3f0fh,3f4fh
  1049.            dw 3f85h,3fb1h,3fd4h,3fech,3ffbh,4000h
  1050.            dw 3ffbh,3fech,3fd4h,3fb1h,3f85h,3f4fh
  1051.            dw 3f0fh,3ec5h,3e72h,3e15h,3dafh,3d3fh
  1052.            dw 3cc5h,3c42h,3bb6h,3b21h,3a82h,39dbh
  1053.            dw 392bh,3871h,37b0h,36e5h,3612h,3537h
  1054.            dw 3453h,3368h,3274h,3179h,3076h,2f6ch
  1055.            dw 2e5ah,2d41h,2c21h,2afbh,29ceh,289ah
  1056.            dw 2760h,2620h,24dah,238eh,223dh,20e7h
  1057.            dw 1f8ch,1e2bh,1cc6h,1b5dh,19efh,187eh
  1058.            dw 1709h,1590h,1413h,1294h,1112h,0f8dh
  1059.            dw 0e06h,0c7ch,0af1h,0964h,07d6h,0646h
  1060.            dw 04b5h,0324h,0192h
  1061.   
  1062. ;
  1063. ; LINIEN-PUNKTE FÜR draw_obj-ROUTINE
  1064. ;
  1065.  
  1066. x1      dw 0
  1067. x2      dw 0
  1068. y1      dw 0
  1069. y2      dw 0
  1070.  
  1071. ;
  1072. ; ECK-PUNKTE FÜR fill_frame-ROUTINE
  1073. ;
  1074.  
  1075. xf1     dw 0
  1076. xf2     dw 0
  1077. yf1     dw 0
  1078. yf2     dw 0
  1079.  
  1080. ;
  1081. ; WINKEL FÜR DIE DREHUNGEN IN X,Y UND Z-RICHTUNG
  1082. ;
  1083.  
  1084. xw      dw 0     
  1085. yw      dw 0
  1086. zw      dw 0
  1087.  
  1088. ;
  1089. ; PUNKTE FÜR FÜLLROUTINE
  1090. ;
  1091.  
  1092. f_x1    dw 0
  1093. f_y1    dw 0
  1094. f_x2    dw 0
  1095. f_y2    dw 0
  1096. f_x3    dw 0
  1097. f_y3    dw 0
  1098.  
  1099. ;
  1100. ; PUFFER FÜR ROTIERTE 3D-KOORDINATEN
  1101. ;
  1102.  
  1103. _3dpoints    dw 3*points DUP (1) ; gedrehte Koord.
  1104.  
  1105. ;
  1106. ; PUFFER FÜR UMGERECHNETE 2D-KOORDINATEN
  1107. ;
  1108.  
  1109. _2dpoints   dw 2*points DUP (1) ; 2D-Koordinaten
  1110.      
  1111. ;
  1112. ; PUFFER FÜR ALTE 2D-KOORDINATEN
  1113. ;
  1114.  
  1115. old2d       dw 2*points dup (0) ; Alte 2D-Koordinaten
  1116.  
  1117. ;
  1118. ; PUFFER FÜR FÜLLKOORDINATEN
  1119. ;
  1120.  
  1121. buffer_pos    dw 0
  1122. buffer_count  dw 0
  1123.  
  1124. fill_buf      dw 1000 dup (?)
  1125.  
  1126.  
  1127. ;
  1128. ; 2D-POINTER FÜR POSITIONIERUNG AUF BILDSCHIRM
  1129. ;
  1130.  
  1131. x_add    dw 160
  1132. y_add    dw 100
  1133.  
  1134. ;
  1135. ; FARBDATEN FÜR DIE GLASFLÄCHEN
  1136. ;
  1137.  
  1138. colorpal db 00,00,00
  1139.          db 00,00,50
  1140.          db 00,00,50
  1141.          db 00,00,40
  1142.  
  1143.  
  1144.  
  1145. ends  data1
  1146.  
  1147. end start
  1148.